/**
 * @file       Button_test.cpp
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#include "Button.h"
#include "gtest/gtest.h"
#include "typedefine.h"
#include "errorcode.h"
#include "Frame.h"
#include "Panel.h"
using namespace NS_LCD_AFW;
using namespace testing;

class CButton_test : public ::testing::Test
{
public:
	virtual void SetUp()
	{
		OBJ_NEW(CPanel,m_pMainPanel);
		m_pMainPanel->create("test",CRect(0,0,10,10));
	}
	virtual void TearDown()
	{
		m_pMainPanel->destory();
		m_pMainPanel = NULL;
	}
protected:
	CPanel *m_pMainPanel;
};
TEST_F(CButton_test,test_defualtConstruction)
{
	CButton *pBtn = new CButton();
	EXPECT_TRUE(pBtn->isHightlightable());
	EXPECT_TRUE(pBtn->isFocusable());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onSetFocus)
{
	CButton *pBtn = new CButton();
	EXPECT_EQ(ERR_SUCCESS, pBtn->create("test",CRect(0,0,2,2),this->m_pMainPanel));
	EXPECT_FALSE(pBtn->isHightlight());
	EXPECT_FALSE(pBtn->hasFocus());
	EXPECT_EQ(ERR_SUCCESS,pBtn->setFocus(true));
	EXPECT_TRUE(pBtn->isHightlight());

	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onLostFocus)
{
	CButton *pBtn = new CButton();
	EXPECT_EQ(ERR_SUCCESS, pBtn->create("test",CRect(0,0,2,2),this->m_pMainPanel));
	EXPECT_FALSE(pBtn->isHightlight());
	EXPECT_FALSE(pBtn->hasFocus());
	EXPECT_EQ(ERR_SUCCESS,pBtn->setFocus(true));
	EXPECT_TRUE(pBtn->isHightlight());
	EXPECT_EQ(ERR_SUCCESS,pBtn->setFocus(false));
	EXPECT_FALSE(pBtn->isHightlight());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onDraw)
{

}
TEST_F(CButton_test,test_onHightlight)
{

}
TEST_F(CButton_test,test_onUnHightlight)
{

}
TEST_F(CButton_test,test_onLeftKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pBtn->onLeftKeyPress());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onBtnClick)
{

}
TEST_F(CButton_test,test_onRightKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_SUCCESS,pBtn->onRightKeyPress());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onEnterKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_SUCCESS,pBtn->onEnterKeyPress());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onCreate)
{

}
TEST_F(CButton_test,test_onEscKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED,pBtn->onEscKeyPress());
	EXPECT_FALSE(pBtn->isHightlight());
	EXPECT_FALSE(pBtn->hasFocus());
	OBJ_DESTORY(pBtn);
}
TEST_F(CButton_test,test_onUpKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED, pBtn->onUpKeyPress());
	EXPECT_FALSE(pBtn->isHightlight());
	EXPECT_FALSE(pBtn->hasFocus());
	OBJ_DESTORY(pBtn);

}
TEST_F(CButton_test,test_onDownKeyPress)
{
	CFrame *pBtn = new CButton();
	EXPECT_EQ(ERR_EVENT_UN_HANDLED, pBtn->onDownKeyPress());
	EXPECT_FALSE(pBtn->isHightlight());
	EXPECT_FALSE(pBtn->hasFocus());
	OBJ_DESTORY(pBtn);
}

